//����div��ʾ
function showwindownewtop(obj,objdiv,addx,addy){

	var x=getposOffset(obj,'left');
    var y=getposOffset(obj,'top');
    var div_obj=document.getElementById(objdiv);
		div_obj.style.left=(x+addx)+'px';
		div_obj.style.top=(y+addy)+'px';
		if(div_obj.style.display=="none"){
		div_obj.style.display="inline";}
		else{
			div_obj.style.display="none";
		}
	}	

function SignOut(){
    var ifru=document.getElementById("usernameifr");
    ifru.src="http://login.dangdang.com/SignOut.aspx?returnurl=http://www.dangdang.com/customer/signout.asp";
   changeuser();
}

function changeuser(){
var nkname=parent.document.getElementById("nickname");
nkname.innerHTML='��ã���ӭ���ٵ�����<a href="http://reco.dangdang.com/">����Ϊ���Ƽ���</a>[��<a href="http://login.dangdang.com/Signin.aspx" name="sign_in" target="_self" class="blue12a">��¼</a>/<a href="http://login.dangdang.com/Register.aspx" target="_self" name="Register" class="blue12a">ע��</a>]';
}



//--------------------header---------
//�������˵�
function showgaoji(obj){
    var x=getposOffset_top(obj,'left');
    var y=getposOffset_top(obj,'top');
	var divotherChannel=document.getElementById("otherChannel"); 
	var img_obj=document.getElementById("img_otherchannel");
	
    var frm=document.searchadvformnewbook;
    var d=new Date();
    var yearn=d.getFullYear(); 
	if(frm){
	if(frm.catalog.value.substring(0,2)=="01"){
		if(frm.sy.options.length<2&&frm.ey.options.length<2){
			for(i=2;i<7;i++){
				var option = new Option(yearn,yearn);
				frm.sy.options.add(option,i);
				var option1 = new Option(yearn,yearn);
				frm.ey.options.add(option1,i);
				yearn--;
			}
		}
	}
	}
	if(img_obj!=null)
		img_obj.src="../images/myhome-img/ddnewhead_arrow_down.gif";
	divotherChannel.style.left=(x-5)+'px';
	if(!isIE_c())
	    divotherChannel.style.top=(y+16)+'px';
	else
	    divotherChannel.style.top=(y+16)+'px';
	divotherChannel.style.display="inline";
    showhideobject(1);    
}

function showhideobject(tr){
	return ;
}

function hideotherchannel(){
		var divotherChannel=document.getElementById("otherChannel");
	var img_obj=document.getElementById("img_otherchannel");
    if(divotherChannel.style.display!="none"){
    divotherChannel.style.display="none";
		if(img_obj!=null){
		img_obj.src="../images/myhome-img/ddnewhead_arrow_up.gif";
		}	
    }
	}


//ͨ�ô��ڹ���
function showwindow(obj,objdiv,addx,addy){
	var x=getposOffset_top(obj,'left');
    var y=getposOffset_top(obj,'top');
    var div_obj=document.getElementById(objdiv);
		div_obj.style.left=(x+addx)+'px';
		div_obj.style.top=(y+addy)+'px';
		div_obj.style.display="inline";
}
	
function Hidewindow(objdiv){
    var div_obj=document.getElementById(objdiv);
		if(div_obj){
			div_obj.style.display="none";
		}
}	


//����
function searchsubmit()
{
	var objfrm=document.searchform;
    if(cnlength(objfrm.key.value)<2)
    {
        alert("搜索词过短，请重新填写！");
        objfrm.key.focus();
        return false;
    } 
    else
    {
           if(cnlength(objfrm.key.value)>70)
           {
                alert(cnlength(objfrm.key.value)+"�����ʹ���������д��");
                objfrm.key.focus();
                return false; 
            }
     }	
    //objfrm.key.value=escape(objfrm.key.value)
	if(objfrm.catalog.value=="readonline")
	{
		window.location="http://search.read.dangdang.com/search.php?"+objfrm.readSearchSelect.value+"="+objfrm.key.value;
		return false;
	}
	if(objfrm.catalog.value>=4000000)
	{
		window.location="http://category.dangdang.com/search?q="+objfrm.key.value+"&guan="+objfrm.catalog.value;
		return false;
	}
	if(objfrm.catalog.value=="01")
		objfrm.action="http://search.book.dangdang.com/search.aspx"
	if(objfrm.catalog.value=="03")
		objfrm.action="http://search.music.dangdang.com/search.aspx"
	if(objfrm.catalog.value=="05")
		objfrm.action="http://search.movie.dangdang.com/search.aspx"
		
	objfrm.submit();
}
function cnlength(str){
    return str.replace(/[^\x00-\xff]/gi,'oo').length;
}

//�����ղ�
function addBookmark(title,url) 
{
	url= window.location.protocol+"//"+window.location.host+url;
    if (window.sidebar) 
        window.sidebar.addPanel(title, url,""); 
    else if( document.all ) 
        window.external.AddFavorite(url, title);
    else if( window.opera && window.print ) 
       return true;
}

//ȡλ��
function getposOffset(what, offsettype)
{ 
    var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop; 
    var parentEl=what.offsetParent; 
    while (parentEl!=null)
    { 
        totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop; 
         parentEl=parentEl.offsetParent; 
    } 
    return totaloffset; 
}

function getposOffset_top(what, offsettype)
{ 
    var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop; 
    var parentEl=what.offsetParent; 
    while (parentEl!=null)
    { 
        totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop; 
         parentEl=parentEl.offsetParent; 
    } 
    return totaloffset; 
}

//ff����
function isIE_c(){ 
   return window.navigator.userAgent.toLowerCase().indexOf("msie")>=1?true:false; 
} 

if(!isIE_c()){ //firefox innerText define
   HTMLElement.prototype.__defineGetter__(     "innerText", 
    function(){
     var anyString = "";
     var childS = this.childNodes;
     for(var i=0; i<childS.length; i++) {
      if(childS[i].nodeType==1)
       anyString += childS[i].tagName=="BR" ? '\n' : childS[i].innerText;
      else if(childS[i].nodeType==3)
       anyString += childS[i].nodeValue;
     }
     return anyString;
    } 
   ); 
   HTMLElement.prototype.__defineSetter__(     "innerText", 
    function(sText){ 
     this.textContent=sText; 
    } 
   ); 
}
